package com.ctsi.common;

import org.springframework.util.StringUtils;

public enum OrgTypeEnum {

    ORG_TYPE_1("虚拟机构", "1"),
    ORG_TYPE_2("单位", "2"),
    ORG_TYPE_3("部门", "3");

    public static OrgTypeEnum matchCode(String codeStr) {
        if (StringUtils.isEmpty(codeStr)) {
            return null;
        }
        for (OrgTypeEnum opCode : OrgTypeEnum.values()) {
            if (opCode.getCode().equalsIgnoreCase(codeStr)) {
                return opCode;
            }
        }
        return null;
    }

    public static String getOrgTypeName(String codeStr) {
        if (StringUtils.isEmpty(codeStr)) {
            return null;
        }
        for (OrgTypeEnum opCode : OrgTypeEnum.values()) {
            if (opCode.getCode().equalsIgnoreCase(codeStr)) {
                return opCode.getName();
            }
        }
        return null;
    }

    OrgTypeEnum(String name, String code) {
        this.code = code;
        this.name = name;
    }

    private String code;
    private String name;

    public String getCode() {
        return code;
    }
    public String getName() {
        return name;
    }


}
